import request from '@/utils/request'

export function getChannelUsableList(query) {
  let baseUrl = "/marketing/channel"
  if(query != undefined){
    if(typeof query == "object"){
      console.log(query)
      if(query.hasOwnProperty('channelID')){
        query['channelID'] = parseInt(query['channelID'])
        if(isNaN(query['channelID']) == false){
          baseUrl = baseUrl+"-"+query['channelID']
        }
      }
    }
  }
  return request({
    url: baseUrl,
    method: 'get'
  })
}

export function getChannelList(query) {
  return request({
    url: '/marketing/admin/channel/getList',
    method: 'post',
    data: query
  })
}
export function saveChannel(query) {
  return request({
    url: '/marketing/admin/channel/save',
    method: 'post',
    data: query
  })
}

export function removeChannel(query) {
  return request({
    url: '/marketing/admin/channel/remove',
    method: 'post',
    data: query
  })
}
export function getChannelDetail(query) {
  if(query != undefined){
    query = JSON.parse(JSON.stringify(query))
  }
  return request({
    url: '/marketing/admin/channel/getDetail',
    method: 'post',
    data: query
  })
}